package main

import (
	"context"
	"fmt"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
	go Done(ctx)
	time.Sleep(2 * time.Second)
	cancel()

}

func Done(ctx context.Context) {
	for {
		time.Sleep(100 * time.Millisecond)
		select {
		case <-ctx.Done():
			fmt.Println("Done")
			return
		default:
			fmt.Println("work")
		}
	}
}
